import mockjs from 'mockjs';

const data = mockjs.mock({
    'list|10': [{
        id: '@id()',
        score: '@integer(0, 10)',
        created_at: '@datetime()',
        name: '@cname()',
    }],
});
export default {
  // 使用 mockjs 等三方库
  'GET /api/stu': (req,res) => {
    res.send({
      code: 200,
      data: data.list,
    })
  },
  'DELETE /api/stu': (req,res) => {
    let {id} = req.body
    if (!id) {
      res.send({
        code: 500,
        msg: '参数错误'
      })
    } else {
      data.list = data.list.filter(item => item.id !== id)
      res.send({
        code: 200,
        data: data.list,
        msg: '删除成功'
      })
    }
  }
}